import io.netty.util.internal.StringUtil;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class GetStaticFileUtils {
    public static String getFileContext(String fileName){
        StringBuilder sb =new StringBuilder();
        InputStream resourceAsStream = GetStaticFileUtils.class.getResourceAsStream(fileName);
        if(resourceAsStream==null){
            return sb.toString();
        }
        try {
            BufferedReader br = new BufferedReader(
                    new InputStreamReader(resourceAsStream,"UTF-8"));
            for (String line = br.readLine(); line != null; line = br.readLine()) {
                if (!StringUtil.isNullOrEmpty(line)) {
                    sb.append(line);
                    sb.append("\r\n");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return sb.toString();
    }

    public static InputStream getFileStream(String fileName){
        return GetStaticFileUtils.class.getResourceAsStream(fileName);
    }


}
